{include file="public/layout" /}
<!--以下是在线编辑器 代码 -->
<script type="text/javascript" charset="utf-8" src="/static/Ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/Ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/Ueditor/lang/zh-cn/zh-cn.js"></script>
<!--以上是在线编辑器 代码  end-->
<style>
    .layui-form-select{z-index: 9999}
    .map-search-res:hover{
        background-color: gray;
    }
    .layui-imgbox-close{width: 25px;height: 22px;right: -18px;top:-10px;}
    #picList .layui-imgbox .layui-imgbox-img{height: auto;}
    #picList .layui-imgbox{margin-right: 25px;height: auto}
</style>
<body class="laytp-container">
<div class="layui-card" >
    <div class="layui-card-header">
        <i class="fa fa-pencil"></i> 编辑商家
    </div>
    <div class="layui-card-body">
        <form class="layui-form open-edit-form" action="">
    <input type="hidden" name="id" value="{$info.id}" />
    <div class="layui-form-item">
        <label class="layui-form-label">商家名称</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" name="name" lay-verify="required" value="{$info.name}" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登录账号</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" name="username" lay-verify="required" value="{$info.username}" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登录密码</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" name="password" placeholder="不填写代表不修改" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商家LOGO1</label>
        <input type="hidden" name="logo" id="logo" class="layui-input" value="{$info.logo}">
        <button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="logo" upload-preview="logoPreview" onclick="uploader(this)">上传图片</button>
        <div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：150×150像素</div>
        <div id="logoPreview" class="picsList-class-padding" style="float:left;padding-top:10px;margin-left:110px;clear: both;">
            <div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info.logo}"/></div></div>
        </div>
    </div>
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">商家介绍</label>-->
<!--        <div class="layui-input-inline layui-input-wrap">-->
<!--            <input type="text" name="desc" placeholder="请输入商家介绍" value="{$info.desc}" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">联系人</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" name="nickname" placeholder="请输入联系人" value="{$info.nickname}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系电话</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" name="mobile" placeholder="请输入联系电话" value="{$info.mobile}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商家照片：</label>
        <input type="hidden" name="pics" value="{$info['pics']}" id="pics">
        <button style="float:left;" type="button" class="layui-btn layui-btn-primary" onclick="uploader(this,true)" upload-input="pics" upload-preview="picList" >批量上传</button>
        <div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：600*340像素</div>
        <div id="picList" class="picsList-class-padding" style="float:left;padding-top:10px;margin-left:110px;clear: both;">
            {if condition="!empty($info['pics'])"}
                <?php $pics = explode(',',$info['pics']);?>
                {foreach $pics as $pic}
                    <div class="layui-imgbox">
                        <a class="layui-imgbox-close" href="javascript:void(0)" onclick="$(this).parent().remove();getpicsval('pics','picList')" title="删除"><i class="layui-icon layui-icon-clear"></i></a>
                        <span class="layui-imgbox-img" style="height: auto;"><img src="{$pic}" onclick="previewImg('{$pic}')"></span>
                    </div>
                {/foreach}
            {/if}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">营业执照：</label>
        <input type="hidden" name="zhengming" value="{$info['zhengming']}" id="zhengming">
        <button style="float:left;" type="button" class="layui-btn layui-btn-primary" onclick="uploader(this,true)" upload-input="zhengming" upload-preview="zhengmingList" >批量上传</button>
        <div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：600*340像素</div>
        <div id="zhengmingList" class="picsList-class-padding" style="float:left;padding-top:10px;margin-left:110px;clear: both;">
            {if condition="!empty($info['zhengming'])"}
            <?php $zhengmings = explode(',',$info['zhengming']);?>
            {foreach $zhengmings as $zhengming}
            <div class="layui-imgbox">
                <a class="layui-imgbox-close" href="javascript:void(0)" onclick="$(this).parent().remove();getpicsval('pics','picList')" title="删除"><i class="layui-icon layui-icon-clear"></i></a>
                <span class="layui-imgbox-img" style="height: auto;"><img src="{$zhengming}" onclick="previewImg('{$zhengming}')"></span>
            </div>
            {/foreach}
            {/if}
        </div>
    </div>
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">微信号：</label>-->
<!--        <div class="layui-input-inline layui-input-wrap" style="width:200px">-->
<!--            <input type="text" name="weixin" class="layui-input" value="{$info.weixin}">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">支付宝：</label>-->
<!--        <div class="layui-input-inline layui-input-wrap" style="width:200px">-->
<!--            <input type="text" name="aliaccount" class="layui-input" value="{$info.aliaccount}">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">开户行：</label>
        <div class="layui-input-inline layui-input-wrap" style="width:200px">
            <input type="text" name="bankname" class="layui-input" value="{$info.bankname}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属分支行：</label>
        <div class="layui-input-inline layui-input-wrap" style="width:200px">
            <input type="text" name="bankbranch" class="layui-input" value="{$info.bankbranch}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">持卡人姓名：</label>
        <div class="layui-input-inline layui-input-wrap" style="width:200px">
            <input type="text" name="bankcarduser" class="layui-input" value="{$info.bankcarduser}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">银行卡号：</label>
        <div class="layui-input-inline" style="width:200px">
            <input type="text" name="bankcardnum" class="layui-input" value="{$info.bankcardnum}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商家地址：</label>
        <div style="display: flex;flex-direction: column;">
            <div class="areaDiv" style="margin-bottom: 8px">
                <div class="layui-input-inline" style="width: 150px">
                    <select name="province" id="province" lay-filter="province" {if !$info}lay-verify="required"{/if}></select>
                </div>
                <div class="layui-input-inline" style="width: 150px">
                    <select name="city" id="city" lay-filter="city"></select>
                </div>
                <div class="layui-input-inline" style="width: 150px" style="display:none">
                    <select name="district" id="district"></select>
                </div>
            </div>
            <div class="adressDiv">
                <div class="layui-input-inline" style="width:500px">
                    <input type="text" id="address" name="address" class="layui-input layui-input-search" value="{$info.address}">
                    <div style="position: absolute;width: 500px;z-index: 100;" class="search-keywords">

                    </div>
                </div>
                <button type="button" class="layui-btn layui-btn-primary" id="searchbtn">搜索</button>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div id="l-map" style="width:600px;height:350px">地图加载中...</div>
        <div style="margin-left:160px;margin-top:10px">
            <div class="layui-input-inline" style="width:200px">
                <input type="text" name="longitude" id="mapjd" class="layui-input" value="{$info.longitude|default='116.39782905578613'}"/>
            </div>
            <div class="layui-input-inline" style="width:200px">
                <input type="text" name="latitude" id="mapwd" class="layui-input" value="{$info.latitude|default='39.90358020251377'}"/>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商家详情：</label>
        <div class="layui-input-inline" style="width:500px">
            <textarea class="span12 ckeditor" id="content" name="content" title="">{$info['content']}</textarea>
        </div>
    </div>

    <if condition="$is_supply eq 0">
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" {if !$info || $info['status']==0}checked{/if} value="0" title="未审核">
            <input type="radio" name="status" {if $info && $info['status']==1}checked{/if} value="1" title="审核通过">
            <input type="radio" name="status" {if $info && $info['status']==2}checked{/if} value="2" title="审核拒绝">
        </div>
    </div>
    </if>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="subbtn">确认</button>
        </div>
    </div>
</form>
    </div>
</div>

<script src="/static/admin/js/searchaddress.js"></script>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key={$qq_map_key}"></script>
<script type="text/javascript" charset="utf-8" src="/static/admin/js/area_select.js"></script>
<script>
    area_select('province','city','district',"{$info.province}","{$info.city}","{$info.district}");
</script>

<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script>
    layui.use(['form', 'laydate', 'util'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6,12}$/,
                '密码必须6到12位，且不能出现空格'
            ]
        });

        // 指定开关事件
        // form.on('switch(switchTest)', function(data){
        //     layer.msg('开关 checked：'+ (this.checked ? 'true' : 'false'), {
        //         offset: '6px'
        //     });
        //     layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是 ON|OFF', data.othis)
        // });

        // 提交事件
        form.on('submit(subbtn)', function(data){
            var index = layer.load();
            layer.close(index);

            var field = data.field; // 获取表单字段值
            $.ajax({
                type: "POST",
                url: "{:url('edit')}",
                data: field,
                success: function(res){
                    console.log(res);
                    if(res.status){
                        layer.msg('提交成功');
                    }else{
                        layer.msg(res.msg);
                    }
                    setTimeout(function(){
                        parent.layer.closeAll();
                        parent.tableIns.reload()
                    },1000)
                }
            });
            return false; // 阻止默认 form 跳转
        });

        // 日期
        laydate.render({
            elem: '#date'
        });


    });
</script>
<script>
    var url="{:url('Ueditor/index',array('savePath'=>'system'))}";
    var ue = UE.getEditor('content',{
        serverUrl :url,
        zIndex: 999,
        initialFrameWidth: "100%", //初化宽度
        initialFrameHeight: 300, //初化高度
        autoHeightEnabled:false,
        focus: false, //初始化时，是否让编辑器获得焦点true或false
        maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
        pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
        autoHeightEnabled: true
    });
    // var url="{:url('Ueditor/index',array('savePath'=>'goods'))}";
    // var ue = UE.getEditor('goods_content',{
    //     serverUrl :url,
    //     zIndex: 999,
    //     initialFrameWidth: "100%", //初化宽度
    //     initialFrameHeight: 300, //初化高度
    //     focus: false, //初始化时，是否让编辑器获得焦点true或false
    //     maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
    //     pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
    //     autoHeightEnabled: true
    // });

</script>
</body>
</html>